def sum_nums(nums,target):
    num_dict = {}
    flag = False
    for i,num in enumerate(nums):
        comp = target - num  #计算差值
        if comp in num_dict:
            print([num_dict[comp],i])
            flag = True
        else:
            num_dict[num] = i
    if(not flag):   #没找到
        print("没找到")

#示例
nums = [1,2,3,4,5,6,7,8,9]
target = 8
#print(sum_nums(nums,target))
sum_nums(nums,target)

